package com.qingkai.onlineshop.presentation.detail

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.qingkai.onlineshop.R
import com.qingkai.onlineshop.ui.theme.OnLineShopAppTheme

/**
 *作者：created by 89270 on 2025/6/17 09:12
 *描述：
 */
@Composable
fun BoxScope.DetailTopBar(backPress: () -> Unit) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .align(Alignment.TopCenter)
            .padding(horizontal = 16.dp)
            .statusBarsPadding(),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.spacedBy(8.dp)
    ) {
        Image(
            painter = painterResource(id = R.drawable.back),
            contentDescription = "back",
            modifier = Modifier
                .clip(CircleShape)
                .clickable { backPress.invoke() }
        )
        Spacer(modifier = Modifier.weight(1f))
        Image(
            painter = painterResource(id = R.drawable.fav), contentDescription = "fav",
            modifier = Modifier
                .clip(CircleShape)
                .clickable { })
        Image(
            painter = painterResource(id = R.drawable.share), contentDescription = "share",
            modifier = Modifier
                .clip(CircleShape)
                .clickable { })
    }

}

@Preview(showBackground = true)
@Composable
fun DetailTopBarPreview() {
    OnLineShopAppTheme {
        Box {
            DetailTopBar(backPress = {})
        }
    }
}